#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void fliplrHelper(char* str, int start, int end) {
    if (start >= end)
        return;
    char tmp = str[start];
    str[start] = str[end];
    str[end] = tmp;
    fliplrHelper(str, start + 1, end - 1);
}

void fliplr(char* str) {
    // 使用文件函数读写，最后一个位置有一个'\n'
    int len = strlen(str) - 1;
    str[len] = '\0';
    fliplrHelper(str, 0, strlen(str) - 1);
}

int main() {
    printf("please input a string:");
    char* stringLine = (char*)malloc(sizeof(char) * 1024);
    int count = 0;

    fgets(stringLine, 1024, stdin);

    fliplr("abcdefg");

    printf("reverse the string: %s\n", stringLine);

    free(stringLine);  
    return 0;
}